﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace B.S.BaseData.Infrastructure.Migrations
{
    public partial class 修改日志记录表 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ApprovalLogs");

            migrationBuilder.DropTable(
                name: "LoginLogs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OperationLogs",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "Id",
                table: "OperationLogs");

            migrationBuilder.RenameColumn(
                name: "Target",
                table: "OperationLogs",
                newName: "UserName");

            migrationBuilder.RenameColumn(
                name: "Remark",
                table: "OperationLogs",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "Operator",
                table: "OperationLogs",
                newName: "MethodName");

            migrationBuilder.RenameColumn(
                name: "OperationType",
                table: "OperationLogs",
                newName: "ErrorMessage");

            migrationBuilder.RenameColumn(
                name: "OperationCode",
                table: "OperationLogs",
                newName: "Description");

            migrationBuilder.RenameColumn(
                name: "Module",
                table: "OperationLogs",
                newName: "AddName");

            migrationBuilder.AddColumn<int>(
                name: "LogId",
                table: "OperationLogs",
                type: "int",
                nullable: false,
                defaultValue: 0)
                .Annotation("SqlServer:Identity", "1, 1");

            migrationBuilder.AddColumn<int>(
                name: "AddId",
                table: "OperationLogs",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<DateTime>(
                name: "AddTime",
                table: "OperationLogs",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<int>(
                name: "DeleteId",
                table: "OperationLogs",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "DeleteName",
                table: "OperationLogs",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "DeleteTime",
                table: "OperationLogs",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsDelete",
                table: "OperationLogs",
                type: "bit",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsSuccess",
                table: "OperationLogs",
                type: "bit",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<int>(
                name: "UpdateId",
                table: "OperationLogs",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "UpdateName",
                table: "OperationLogs",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "UpdateTime",
                table: "OperationLogs",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_OperationLogs",
                table: "OperationLogs",
                column: "LogId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_OperationLogs",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "LogId",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "AddId",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "AddTime",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "DeleteId",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "DeleteName",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "DeleteTime",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "IsDelete",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "IsSuccess",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "UpdateId",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "UpdateName",
                table: "OperationLogs");

            migrationBuilder.DropColumn(
                name: "UpdateTime",
                table: "OperationLogs");

            migrationBuilder.RenameColumn(
                name: "UserName",
                table: "OperationLogs",
                newName: "Target");

            migrationBuilder.RenameColumn(
                name: "UserId",
                table: "OperationLogs",
                newName: "Remark");

            migrationBuilder.RenameColumn(
                name: "MethodName",
                table: "OperationLogs",
                newName: "Operator");

            migrationBuilder.RenameColumn(
                name: "ErrorMessage",
                table: "OperationLogs",
                newName: "OperationType");

            migrationBuilder.RenameColumn(
                name: "Description",
                table: "OperationLogs",
                newName: "OperationCode");

            migrationBuilder.RenameColumn(
                name: "AddName",
                table: "OperationLogs",
                newName: "Module");

            migrationBuilder.AddColumn<long>(
                name: "Id",
                table: "OperationLogs",
                type: "bigint",
                nullable: false,
                defaultValue: 0L)
                .Annotation("SqlServer:Identity", "1, 1");

            migrationBuilder.AddPrimaryKey(
                name: "PK_OperationLogs",
                table: "OperationLogs",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "ApprovalLogs",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AddId = table.Column<int>(type: "int", nullable: false),
                    AddName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ApprovalCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ApprovalResult = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ApprovalType = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Approver = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    BusinessCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DeleteId = table.Column<int>(type: "int", nullable: true),
                    DeleteName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SubmitTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateId = table.Column<int>(type: "int", nullable: false),
                    UpdateName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ApprovalLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LoginLogs",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AddId = table.Column<int>(type: "int", nullable: false),
                    AddName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    BrowserVersion = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DeleteId = table.Column<int>(type: "int", nullable: true),
                    DeleteName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeviceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Location = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LoginIP = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LoginTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    MACAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    OS = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    TerminalType = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    UpdateId = table.Column<int>(type: "int", nullable: false),
                    UpdateName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LoginLogs", x => x.Id);
                });
        }
    }
}
